//
//  UserViewController2.m
//  UI_元旦豆瓣
//
//  Created by dllo on 16/1/3.
//  Copyright © 2016年 31付冬梅. All rights reserved.
//

#import "UserViewController2.h"
#import "LTView.h"
#import "UserViewController3.h"
#import "UserDataBaseHandle.h"
#import "UserModel.h"
@interface UserViewController2 ()<UITextFieldDelegate>

@property (nonatomic, retain) NSMutableArray *userModelArr;
@property (nonatomic, retain) UIView *view1;
@property (nonatomic, retain) UIView *view2;
@end

@implementation UserViewController2
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor yellowColor];
    self.title = @"登陆";
    LTView *view1 = [[LTView alloc] initWithFrame:CGRectMake(50, 100, 300, 50)];
    view1.backgroundColor = [UIColor clearColor];
    view1.myLabel.text = @"用户名";
    view1.myTextField.placeholder = @"请输入用户名";
    view1.myTextField.keyboardType = UIKeyboardTypeAlphabet;
    view1.myTextField.delegate = self;
    [self.view addSubview:view1];
    
    
    LTView *view2 = [[LTView alloc] initWithFrame:CGRectMake(50, 200, 300, 50)];
    view2.backgroundColor = [UIColor clearColor];
    view2.myLabel.text = @"密码";
    view2.myTextField.placeholder = @"请输入密码";
    view2.myTextField.secureTextEntry = YES;
    view2.myTextField.keyboardType = UIKeyboardTypeEmailAddress;
    view2.myTextField.delegate = self;
    [self.view addSubview:view2];
    
    
    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
    button1.frame = CGRectMake(50, 300, 80, 50);
    button1.backgroundColor = [UIColor clearColor];
    [button1 setTitle:@"登陆" forState:UIControlStateNormal];
    [button1 setTitleColor:[UIColor purpleColor] forState:UIControlStateNormal];
    [button1 addTarget:self action:@selector(buttonAction1:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button1];
    
    
    
    UIButton *button2 = [UIButton buttonWithType:UIButtonTypeCustom];
    button2.frame = CGRectMake(150, 300, 80, 50);
    button2.backgroundColor =[UIColor clearColor];
    [button2 setTitle:@"注册" forState:UIControlStateNormal];
    [button2 setTitleColor:[UIColor purpleColor] forState:UIControlStateNormal];
    [button2 addTarget:self action:@selector(buttonAction2:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button2];
    //
    //    UIButton *button3 = [UIButton buttonWithType:UIButtonTypeCustom];
    //    button3.frame = CGRectMake(250, 300, 80, 50);
    //    button3.backgroundColor = [UIColor clearColor];
    //    [button3 setTitleColor:[UIColor purpleColor] forState:UIControlStateNormal];
    //    [button3 setTitle:@"取消" forState:UIControlStateNormal];
    //    [button3 addTarget:self action:@selector(buttonAction3:) forControlEvents:UIControlEventTouchUpInside];
    //    [self.view addSubview:button3];
}
- (void)buttonAction1:(UIButton *)button1 {
    UIAlertController *alert1 = [UIAlertController alertControllerWithTitle:@"登陆" message:@"登陆成功" preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//        LTView *view = [[LTView alloc] init];
//        self.userModelArr = [[UserDataBaseHandle sharedUserDataBaseHandle] selectUserTable];
//        UserModel *model = [UserModel userModel];
//        if ([view.myTextField.placeholder isEqualToString:@"请输入用户名"]) {
//            model.userName = view.myTextField.text;
//        }
//        if ([view.myTextField.placeholder isEqualToString:@"请输入密码"]) {
//            model.password = view.myTextField.text;
//        }
//        [_userModelArr addObject:model];
        
        
        
    [self dismissViewControllerAnimated:YES completion:^{
        self.str = @"注销";
        
        
        
    }];
        
    }];
    [alert1 addAction:action];
    [self presentViewController:alert1 animated:YES completion:^{
        
    }];
    
}
- (void)buttonAction2:(UIButton *)button2 {
    UserViewController3 *view3 = [[UserViewController3 alloc] init];
    
    [self presentViewController:view3 animated:YES completion:^{
        
    }];
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    [textField resignFirstResponder];
    return YES;

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
